﻿// -----------------------------------------------------------------------
// <copyright file="ThanhPhanMap.cs" company="">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace BloodThirsty
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.Xna.Framework.Graphics;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public class ThanhPhanMap
    {
        private Texture2D _tPMap;

        public Texture2D TPMap
        {
            get { return _tPMap; }
            set { _tPMap = value; }
        }

        private double _Left;

        public double Left
        {
            get { return _Left; }
            set { _Left = value; }
        }
        private double _Top;

        public double Top
        {
            get { return _Top; }
            set { _Top = value; }
        }

        public ThanhPhanMap(Texture2D Map, double left, double top)
        {
            TPMap = Map;
            Left = left;
            Top = top;
        }

        //ham nay tra ra vi tri left va top cua moi manh map 
        //Dau vao : iTexture va nTexture
        
        public void TinhVitri(int i,int n)
        {
            // 512 la do lon cua width va height cua 1 tam anh map
            // 8 la so tam anh map tren 1 dong
            int j = 1;
            while (8 * j > i)
            {
                j++;
            }
            // ta coi map la 1 mang hai chieu. Nen can phai tim dc vi tri tung va hoanh cua map
            // Khi co vi tri tung do ta nhan 512 ra dc Top, tuong tu cho hoanh do de ra dc left 
            Top = (j - 1) * 512;
            Left = ((i - ((j - 1) * 8)) *512);//(i-(j-1)*8) lay ra dc khoang cach giua tam map thu i va tam map dau dong
        }

    }
}
